﻿using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;

namespace ChangDiTools {
    /// <summary>
    /// WPFWindow.xaml 的交互逻辑
    /// </summary>
    public partial class WPFWindow : Window {
        public WPFWindow() {
            InitializeComponent();
        }

        private void ButtonGrid_Click(object sender, RoutedEventArgs e) {
            Close();
            Tools.CreateGridLine();

        }

        private void ButtonRoadSlope_Click(object sender, RoutedEventArgs e) {
            Close();
            Tools.RoadSlope();
        }

        private void ButtonZB_Click(object sender, RoutedEventArgs e) {
            Close();
            int n = ComboBox1.SelectedIndex;
            string jd = "f" + n;
            Tools.CoordinateCallOut(jd);
        }

        private void ButtonRoadDTZB_Click(object sender, RoutedEventArgs e) {
            Close();
            if (RadioButton2.IsChecked == true) {//设置系统变量
                Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("FIELDDISPLAY", 0);
            }
            else {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("FIELDDISPLAY", 1);
            }
            int n = ComboBox1.SelectedIndex;
            Tools.CoordinateCallOut1(n);
        }

        private void ButtonRoadPLZB_Click(object sender, RoutedEventArgs e) {
            Close();
            int n = ComboBox1.SelectedIndex;
            string jd = "f" + n;
            Tools.GetPolylineCoordinat(jd);
        }

        private void linkDmsite_Click(object sender, RoutedEventArgs e) {
            Hyperlink link = sender as Hyperlink;
            Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
        }

        private void ButtonBG_Click(object sender, RoutedEventArgs e) {
            Close();
            int n = ComboBox2.SelectedIndex;
            string jd = "f" + n;
            Tools.GetEle(jd);
        }

        private void ButtonPLBG_Click(object sender, RoutedEventArgs e) {
            Close();
            int n = ComboBox2.SelectedIndex;
            string jd = "f" + n;
            Tools.GetPolylineEle(jd);
        }

        private void ButtonPD_OnClick(object sender, RoutedEventArgs e) {
            Close();
            int n = ComboBox2.SelectedIndex;
            string height = TextBox1.Text;
            double tHeight = double.Parse(height) / 5;
            Tools.GetSlope(n, tHeight);
        }

        private void ButtonPLPD_OnClick(object sender, RoutedEventArgs e) {
            Close();
            int n = ComboBox2.SelectedIndex;
            string height = TextBox1.Text;
            double tHeight = double.Parse(height) / 5;
            Tools.GetPolylineSlpoe(n, tHeight);
        }

        private void ButtonDaocha_Click(object sender, RoutedEventArgs e) {
            Close();
            Tools.DaoCha();
        }

        private void ButtonText1_Click(object sender, RoutedEventArgs e)
        {
            Close();
            string c = TextBox2.Text;
            Tools.GetText1(c, RadioButton3.IsChecked);
        }
    }
}
